package routes

import (
	"fmt"
	// "net/http"
	"go-copyright/utils" //引入通用函数utils包

	"github.com/labstack/echo"
	"github.com/labstack/echo-contrib/session"
)

/**
get session
**/
func GetSession(c echo.Context) error {
	var resp utils.Resp
	resp.Errno = utils.RECODE_OK
	defer utils.ResponseData(c, &resp)

	//处理session
	sess, err := session.Get("session", c)
	if err != nil {
		fmt.Println("failed to get session")
		resp.Errno = utils.RECODE_SESSIONERR
		return err
	}
	address := sess.Values["address"]
	if address == nil {
		fmt.Println("failed to get session,address is nil")
		resp.Errno = utils.RECODE_SESSIONERR
		return err
	}
	return nil
}
